public class ExceptionHandlerMethodResolver
extends java.lang.Object
@ExceptionHandler
annotation or by looking at the signature of an @ExceptionHandler
method.Modifier and Type | Field and Description |
---|---|
static ReflectionUtils.MethodFilter |
EXCEPTION_HANDLER_METHODS
A filter for selecting
@ExceptionHandler methods. |
private java.util.Map<java.lang.Class<? extends java.lang.Throwable>,java.lang.reflect.Method> |
exceptionLookupCache |
private java.util.Map<java.lang.Class<? extends java.lang.Throwable>,java.lang.reflect.Method> |
mappedMethods |
private static java.lang.reflect.Method |
NO_METHOD_FOUND |
Constructor and Description |
---|
ExceptionHandlerMethodResolver(java.lang.Class<?> handlerType)
A constructor that finds
ExceptionHandler methods in the given type. |
Modifier and Type | Method and Description |
---|---|
private void |
addExceptionMapping(java.lang.Class<? extends java.lang.Throwable> exceptionType,
java.lang.reflect.Method method) |
private java.util.List<java.lang.Class<? extends java.lang.Throwable>> |
detectExceptionMappings(java.lang.reflect.Method method)
Extract exception mappings from the
@ExceptionHandler annotation
first and as a fall-back from the method signature. |
private java.lang.reflect.Method |
getMappedMethod(java.lang.Class<? extends java.lang.Exception> exceptionType)
Return the method mapped to the given exception type or
null . |
boolean |
hasExceptionMappings()
Whether the contained type has any exception mappings.
|
java.lang.reflect.Method |
resolveMethod(java.lang.Exception exception)
Find a method to handle the given exception.
|
private static final java.lang.reflect.Method NO_METHOD_FOUND
private final java.util.Map<java.lang.Class<? extends java.lang.Throwable>,java.lang.reflect.Method> mappedMethods
private final java.util.Map<java.lang.Class<? extends java.lang.Throwable>,java.lang.reflect.Method> exceptionLookupCache
public static final ReflectionUtils.MethodFilter EXCEPTION_HANDLER_METHODS
@ExceptionHandler
methods.public ExceptionHandlerMethodResolver(java.lang.Class<?> handlerType)
ExceptionHandler
methods in the given type.handlerType
- the type to introspectprivate java.util.List<java.lang.Class<? extends java.lang.Throwable>> detectExceptionMappings(java.lang.reflect.Method method)
@ExceptionHandler
annotation
first and as a fall-back from the method signature.private void addExceptionMapping(java.lang.Class<? extends java.lang.Throwable> exceptionType, java.lang.reflect.Method method)
public boolean hasExceptionMappings()
public java.lang.reflect.Method resolveMethod(java.lang.Exception exception)
ExceptionDepthComparator
if more than one match is found.exception
- the exceptionnull
private java.lang.reflect.Method getMappedMethod(java.lang.Class<? extends java.lang.Exception> exceptionType)
null
.